@echo off

goto check_syntax

:continue
if "%2" == "" goto default_folder
if "%2" == "Test" goto test_folder
set TOOL_TARGETDIR=%2

:install

@echo *******************************************************
@echo *  Install Windows service
@echo *******************************************************

pushd %TOOL_TARGETDIR%
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\installutil %1 StockholmsStad.WindowsService.exe
popd

goto end

:default_folder
@echo *************************************************************
@echo *
@echo * No source folder specified!
@echo * Folder assumed
@echo * C:\Program Files\Parvis
@echo *
@echo *************************************************************
@pause
if "%ProgramFiles(x86)%" == "" goto win32bit
set TOOL_TARGETDIR=%Programfiles(x86)%\Parvis
goto install

:win32bit
set TOOL_TARGETDIR=%Programfiles%\Parvis
goto install


:test_folder
@echo *************************************************************
@echo *
@echo * No source folder specified!
@echo * Folder assumed
@echo * C:\Program Files\ParvisTest
@echo *
@echo *************************************************************
@pause
if "%ProgramFiles(x86)%" == "" goto win32bitTest
set TOOL_TARGETDIR=%Programfiles(x86)%\ParvisTest
goto install

:win32bitTest
set TOOL_TARGETDIR=%Programfiles%\ParvisTest
goto install

:check_syntax
if "%1" == "" goto syntax_error
if "%1" == "/i" goto continue
if "%1" == "/u" goto continue

:syntax_error
echo *************************************************************
echo *
echo * Syntax error!
echo * Required parameter is missing.
echo *
echo * Usage: InstallWinService "/i | /u" [SourceFolder]
echo *
echo *************************************************************
goto end

:end
@pause
